package Exercise2;
//定义数组存储3个汽车对象
//商品的属性:品牌，价格，颜色
//创建三个汽车对象，数据通过键盘录入而来，并把数据存入到数组当中
import java.util.Scanner;

public class CarTest {
    public static void main(String[] args) {
        Car[] arr = new Car[3];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            Car c = new Car();
            System.out.println("请输入汽车品牌：");
            String brand = sc.next();
            c.setBrand(brand);
            System.out.println("请输入汽车价格：");
            double price = sc.nextDouble();
            c.setPrice(price);
            System.out.println("请输入汽车颜色：");
            String color = sc.next();
            c.setColor(color);
            arr[i] = c;
        }

        for (int i = 0; i < arr.length; i++) {
            Car car = arr[i];
            System.out.println(car.getBrand()+","+car.getPrice()+","+car.getColor());
        }

    }
}
